package com.easyctrl.dialog;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.easyctrl.ldy.activity.R;
import com.easyctrl.ui.base.BaseDialog;

public class SimpleDialog extends BaseDialog implements OnClickListener{

	public interface OnOptionListener {
		public void onEnter();
	}
	
	private OnOptionListener onOptionListener;
	
	private TextView textView;
	private String title;
	public SimpleDialog(Context context) {
		super(context); 
		setContentView(R.layout.simple_dialog);
		textView = (TextView) findViewById(R.id.textisExit);
		findViewById(R.id.cancel).setOnClickListener(this);
		findViewById(R.id.enter).setOnClickListener(this);
	}
	
	@Override
	public void show() {
		if(title != null) {
			textView.setText(title);
		}
		super.show();
	}
	
	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public void onClick(View v) { 
		
		if(R.id.cancel == v.getId()) {
			dismiss();
		}else if(R.id.enter == v.getId()) {
			dismiss();
			if(onOptionListener != null){
				onOptionListener.onEnter();
			}
		}
	}

	public void setOnOptionListener(OnOptionListener onOptionListener) {
		this.onOptionListener = onOptionListener;
	}  
}
